package cn.edu.wdu.gaojie.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author gaojie  gao4433@qq.com
 * @Description JDBC 之【修改操作】
 * @date 2021/12/2 15:38
 * @since 1.8
 */
public class AppJdbcUpdate {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");

        String url = "jdbc:mysql://localhost:3306/test?useSSL=false";
        String userName = "root";
        String passWord = "778874315";

        Connection connection = DriverManager.getConnection(url, userName, passWord);

        Statement statement = connection.createStatement();
        String sql = "UPDATE `user` SET `username` = 'Tina' WHERE id = 1";
        int i = statement.executeUpdate(sql);
        if (i > 0){
            System.out.println("修改成功！");
        }

    }
}
